#ifndef __SDL_SS2D_H__
#define __SDL_SS2D_H__

#include "SDL2/SDL.h"
#include "BannerClass.h"
#include "commButtonClass.h"

typedef struct SSD_DRIVER
{
    int32_t image_init_flags;           // +0(+0)     image_init_flags
    int32_t driver_init_flags;          // +1(+4)     driver_init_flags
    char *video_driver_name;            // +2(+8)     video_driver_name
    int32_t unk_3;                      // +3(+12)
    int32_t unk_4;                      // +4(+16)
    int32_t unk_5;                      // +5(+20)
    int32_t window_flags;               // +6(+24)    window flags
    int32_t unk_7;                      // +7(+28)
    int32_t unk_8;                      // +8(+32)
    int32_t screen_width;               // +9(+36)    screen_width
    int32_t screen_height;              // +10(+40)   screen_height
    int32_t game_width;                 // +11(+44)   game_width
    int32_t game_height;                // +12(+48)   game_height
    int32_t max_width;                  // +13(+52)   max_window_width
    int32_t max_height;                 // +14(+56)   max_window_height
    int32_t renderer_w;                 // +15(+60)   renderer_w
    int32_t renderer_h;                 // +16(+64)   renderer_h
    int32_t renderer_scale;             // +17(+68)   renderer_scale
    int32_t pixelFormat_bpp;            // +18(+72)   pixelFormat_bpp
    int32_t unk_19;                     // +19(+76)
    int32_t RGB32Surface_pitch;         // +20(+80)   RGB32Surface pitch
    int32_t unk_21;                     // +21(+84)
    int32_t max_window_num;             // +22(+88)   max windows num
    SDL_Window **windows;               // +23(+92)   Window
    int32_t unk_24;                     // +24(+96)
    int32_t unk_25;                     // +25(+100)
    int32_t unk_26;                     // +26(+104)
    int32_t unk_27;                     // +27(+108)
    int32_t unk_28;                     // +28(+112)
    char *renderer_driver_name;         // +29(+116)  renderer_driver_name
    int32_t unk_30;                     // +30(+120)
    int32_t unk_31;                     // +31(+124)
    SDL_Renderer **renderers;           // +32(+128)  Renderer
    char *audio_driver_name;            // +33(+132)  audio_driver_name
    uint32_t sample_rate;               // +34(+136)  音频采样率 (22050)
    int32_t audio_vol;                  // +35(+140)  音量?     (-32752)
    int32_t unk_36;                     // +36(+144)  unk      （256)
    int32_t unk_37;                     // +37(+148)
    int32_t (*audio_callback)(void);    // +38(+152)  audio callback
    int32_t unk_39;                     // +39(+156)
    int32_t unk_40;                     // +40(+160)
    int32_t unk_41;                     // +41(+164)
    int32_t unk_42;                     // +42(+168)
    int32_t unk_43;                     // +43(+172)
    int32_t unk_44;                     // +44(+176)
    int32_t unk_45;                     // +45(+180)
    int32_t unk_46;                     // +46(+184)
    int32_t unk_47;                     // +47(+188)
    int32_t unk_48;                     // +48(+192)
    int32_t unk_49;                     // +49(+196)
    int32_t gl_red_size;                // +50(+200) SDL_GL_RED_SIZE
    int32_t gl_green_size;              // +51(+204) SDL_GL_GREEN_SIZE
    int32_t gl_blue_size;               // +52(+208) SDL_GL_BLUE_SIZE
    int32_t gl_alpha_size;              // +53(+212) SDL_GL_ALPHA_SIZE
    int32_t gl_buffer_size;             // +54(+216) SDL_GL_BUFFER_SIZE
    int32_t gl_doublebuffer;            // +55(+220) SDL_GL_DOUBLEBUFFER
    int32_t gl_depth_size;              // +56(+224) SDL_GL_DEPTH_SIZE
    int32_t gl_stencil_size;            // +57(+228) SDL_GL_STENCIL_SIZE
    int32_t gl_accum_red_size;          // +58(+232) SDL_GL_ACCUM_RED_SIZE
    int32_t gl_accum_green_size;        // +59(+236) SDL_GL_ACCUM_GREEN_SIZE
    int32_t gl_accum_blue_size;         // +60(+240) SDL_GL_ACCUM_BLUE_SIZE
    int32_t gl_accum_alpha_size;        // +61(+244) SDL_GL_ACCUM_ALPHA_SIZE
    int32_t gl_stereo;                  // +62(+248) SDL_GL_STEREO
    int32_t gl_multisamplebuffers;      // +63(+252) SDL_GL_MULTISAMPLEBUFFERS
    int32_t gl_multisamplesamples;      // +64(+256) SDL_GL_MULTISAMPLESAMPLES
    int32_t gl_retained_backing;        // +65(+260) SDL_GL_RETAINED_BACKING
    int32_t gl_accelerated_visual;      // +66(+264) SDL_GL_ACCELERATED_VISUAL
    int32_t gl_context_major_version;   // +67(+268) SDL_GL_CONTEXT_MAJOR_VERSION
    int32_t gl_context_minjor_version;  // +68(+272) SDL_GL_CONTEXT_MINOR_VERSION
    int32_t gl_context_egl;             // +69(+276) SDL_GL_CONTEXT_EGL
    SDL_Joystick *joystick;             // +70(+280) joystick
    SDL_GameController *gamecontroller; // +71(+284) gamecontroller
} SSD_DRIVER;                           // sizeof = 72 * 4 = 288;

typedef struct SDL_SS2D
{
    SSD_DRIVER *driver;                // +0
    SDL_Surface *main_surface;         // +1(+4) --- 最终完成的 surface
    SDL_Texture *main_texture;         // +2(+8) --- 最终完成的 texture
    void *display_surface_pixels_base; // +3_4
    void *display_surface_pixels_p;    // +3_4
    BannerClass banner_class;          // +5_20
    SDL_Rect render_rect;              // +21(+84)  render rect 4 * 4 （屏幕渲染坐标）
    float *w_scale_x;                  // +25(+100) window scale x ??
    float *w_scale_y;                  // +26(+104) window scale y ??
    float *w_s_scale_x;                // +27(+108) window_w / screen_w
    float *w_s_scale_y;                // +28(+112) window_h / screen_h
    float *s_w_scale_x;                // +29(+116) screen_w / window_w
    float *s_w_scale_y;                // +30(+120) screen_h / window_h
    int32_t unk_31;                    // +31
    int32_t window_width;              // +32   window width
    int32_t window_height;             // +33   window height
    SDL_Surface *bg_surface;           // +34   BG surface
    SDL_Texture *bg_texture;           // +35   BG texture

    int32_t unk_36_37[2];              // +36_37 unk 2 * 4
    SDL_Surface *MenuBackground1_surf; // +38

    commButtonClass SysSave_ButtonClass;    // +39
    commButtonClass SysLoad_ButtonClass;    // +55
    commButtonClass SysJournal_ButtonClass; // +71
    commButtonClass SysSetting_ButtonClass; // +87
    commButtonClass SysExit_ButtonClass;    // +103
    commButtonClass Buy_ButtonClass;        // +119
    commButtonClass Sell_ButtonClass;       // +135
    commButtonClass BackIcon_ButtonClass;   // +151
    commButtonClass PlusIcon_ButtonClass;   // +167
    commButtonClass MinusIcon_ButtonClass;  // +183
    commButtonClass FBackIcon_ButtonClass;  // +199

    SDL_Surface *conversion_surface;    // +215 用于转换的surface(rgb32)
    SDL_Surface *MenuIcon1_surf;        // +216
    SDL_Surface *MenuIcon2_surf;        // +217
    SDL_Surface *MenuIcon3_surf;        // +218
    SDL_Surface *MenuIcon4_surf;        // +219
    SDL_Surface *MenuIcon5_surf;        // +220
    SDL_Surface *eventStar01_surf;      // +221
    SDL_Surface *eventStar02_surf;      // +222
    SDL_Surface *eventStar03_surf;      // +223
    SDL_Surface *eventStar04_surf;      // +224
    SDL_Surface *eventStar05_surf;      // +225
    int32_t MenuIcon_ticks0;            // +226
    int32_t MenuIcon_ticks1;            // +227
    int32_t MenuIcon_ticks_start;       // +228
    int32_t AcceptIcon_clicked;         // +229
    SDL_Surface *AcceptIcon_surf;       // +230
    SDL_Surface *AcceptIconClick_surf;  // +231
    int32_t AcceptIcon_x;               // +232
    int32_t AcceptIcon_y;               // +233
    int32_t unk_234_235[2];             // +234_235 unk 2 * 4
    SDL_Surface *AutoON_surf;           // +236
    SDL_Surface *AutoOFF_surf;          // +237
    SDL_Surface *Retreat_surf;          // +238
    SDL_Surface *RetreatClick_surf;     // +239
    int32_t ItemF1_x;                   // +240
    int32_t ItemF1_y;                   // +241
    SDL_Surface *ItemF1_surf;           // +242
    SDL_Surface *ItemF1Click_surf;      // +243
    int32_t ItemF2_x;                   // +244
    int32_t ItemF2_y;                   // +245
    SDL_Surface *ItemF2_surf;           // +246
    SDL_Surface *ItemF2Click_surf;      // +247
    int32_t ItemF3_x;                   // +248
    int32_t ItemF3_y;                   // +249
    SDL_Surface *ItemF3_surf;           // +250
    SDL_Surface *ItemF3Click_surf;      // +251
    int32_t HintWebIcon_x;              // +252
    int32_t HintWebIcon_y;              // +253
    int32_t HintWebIcon_unk254;         // +254
    SDL_Surface *HintWebIcon_surf;      // +255
    SDL_Surface *HintWebIconClick_surf; // +256
    int32_t unk_257;                    // +257
    int32_t unk_258;                    // +258
    uint8_t JoyStick_inited;            // +259 (+1036)  JoyStick_inited
    int8_t unk_1037;                    //      (+1037)
    int8_t unk_1038;                    //      (+1038)
    int8_t unk_1039;                    //      (+1039)
    uint32_t unk_260;                   // +260
    uint32_t unk_261;                   // +261
    uint32_t unk_262;                   // +262
    uint32_t unk_263;                   // +263
    uint32_t unk_264;                   // +264
    uint32_t unk_265;                   // +265
    uint32_t unk_266;                   // +266
    uint32_t unk_267;                   // +267
    uint32_t unk_268;                   // +268
    uint32_t unk_269;                   // +269
    uint32_t unk_270;                   // +270
    uint32_t unk_271;                   // +271
    FILE *all_char_stream;              // +272   all_char.tsw
    FILE *all_item_stream;              // +273   all_item.tsw
    FILE *all_magic_stream;             // +274   all_magic.tsw
    FILE *all_sys_stream;               // +275   all_sys.tsw
    FILE *all_map1_stream;              // +276   all_map1.tsw
    FILE *all_map2_stream;              // +277   all_map2.tsw
    uint32_t unk_280_306[29];           // +278
} SDL_SS2D;                             // size = 1228 (307 * 4);

#endif
